const net = require('net');

const html = `<h1>TCP</h1>`
const responeseHeaders = [
    'HTTP/1.1 200 OK',
    'Content-Type: text/html; charset=utf-8',
    'Conten-Length: ' + html.length,
    '\r\n',
    html
]
const http = net.createServer(socket => {
    socket.on('data', data => {
        if (/GET/.test(data.toString())) {
            socket.write(responeseHeaders.join("\r\n"))
            socket.end();
        }
    })
})

http.listen(80, () => {
    console.log('listen 80')
})
